<template>
  <div class="min-h-screen bg-gradient-to-br from-gray-50 via-blue-50 to-indigo-50">
    <!-- 背景装饰 -->
    <div class="fixed inset-0 overflow-hidden pointer-events-none">
      <div class="absolute -top-40 -right-40 w-80 h-80 bg-blue-200 rounded-full mix-blend-multiply filter blur-xl opacity-20 animate-blob"></div>
      <div class="absolute -bottom-40 -left-40 w-80 h-80 bg-purple-200 rounded-full mix-blend-multiply filter blur-xl opacity-20 animate-blob animation-delay-2000"></div>
      <div class="absolute top-40 left-40 w-80 h-80 bg-pink-200 rounded-full mix-blend-multiply filter blur-xl opacity-20 animate-blob animation-delay-4000"></div>
    </div>

    <!-- 主要内容区域 -->
    <div class="container mx-auto px-12 py-10 pt-32 relative z-10">
      <!-- 顶部：返回与标题 -->
      <div class="flex items-center justify-between mb-10">
        <div class="flex items-center gap-4">
          <el-button type="primary" link @click="goBack" class="text-gray-600 hover:text-gray-800 text-lg">
            <el-icon class="mr-2 text-xl">
              <ArrowLeft />
            </el-icon>
            返回班级详情
          </el-button>
          <h1 class="text-4xl font-bold text-gray-900">知识点</h1>
        </div>
      </div>

      <!-- 主体内容 -->
      <div class="bg-white rounded-3xl shadow-xl border border-gray-200 overflow-hidden">
        <div class="px-8 py-6 border-b border-gray-200 bg-gradient-to-r from-blue-50 to-indigo-50">
          <div class="flex items-center justify-between">
            <div class="flex items-center gap-4">
              <div class="w-16 h-16 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-2xl flex items-center justify-center">
                <el-icon class="text-white text-2xl">
                  <Reading />
                </el-icon>
              </div>
              <div>
                <h3 class="text-3xl font-bold text-gray-900 mb-2">班级知识点</h3>
                <p class="text-blue-600 font-medium text-xl">查看班级相关知识点</p>
              </div>
            </div>
          </div>
        </div>

        <!-- 知识点列表 -->
        <div class="p-8">
          <div v-if="knowledgePoints.length === 0" class="text-center py-20">
            <div class="w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-6">
              <el-icon class="text-gray-400 text-4xl">
                <Document />
              </el-icon>
            </div>
            <h3 class="text-xl font-semibold text-gray-500 mb-4">暂无知识点</h3>
          </div>

          <div v-else class="space-y-6">
            <div v-for="point in knowledgePoints" :key="point.id" class="border border-gray-200 rounded-2xl p-6 hover:shadow-lg transition-shadow">
              <div class="flex justify-between items-start mb-4">
                <h4 class="text-2xl font-bold text-gray-900">{{ point.title }}</h4>
                <div class="flex gap-2">
                </div>
              </div>
              
              <div class="text-gray-700 mb-6 leading-relaxed">{{ point.content }}</div>
              
              <div class="flex flex-wrap gap-3 mb-6">
                <span v-for="tag in point.tags" :key="tag" class="bg-blue-100 text-blue-800 text-sm px-3 py-1 rounded-full">{{ tag }}</span>
              </div>
              
              <div class="flex justify-between items-center text-gray-500 text-sm">
                <span>发布于 {{ formatDate(point.createTime) }}</span>
                <el-button type="text" @click="handleViewDetails(point)" class="text-blue-600">
                  查看详情 <el-icon class="ml-1">
                    <ArrowRight />
                  </el-icon>
                </el-button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>
</template>

<script setup>
import { ref, onMounted, reactive, toRefs } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ArrowLeft, Reading, Plus, Edit, Delete, Document } from '@element-plus/icons-vue'

const route = useRoute()
const router = useRouter()
const classId = ref(route.params.id)

// 班级信息
const classInfo = ref({
  className: ''
})

// 知识点列表
const knowledgePoints = ref([
  {
    id: 1,
    title: 'Vue组件通信方式',
    content: 'Vue组件间通信主要有以下几种方式：props、$emit、vuex/pinia、provide/inject、eventBus、$parent/$children等。根据不同的使用场景选择合适的通信方式。',
    tags: ['Vue', '组件', '前端'],
    createTime: '2023-10-15T08:30:00'
  },
  {
    id: 2,
    title: 'HTTP请求方法',
    content: '常见的HTTP请求方法包括GET、POST、PUT、DELETE、PATCH等，分别对应查询、创建、更新、删除、部分更新等操作。',
    tags: ['HTTP', '网络', '后端'],
    createTime: '2023-10-16T14:20:00'
  }
])


// 获取班级信息
const getClassInfo = () => {
  // 实际项目中这里会调用API获取班级信息
  classInfo.value = {
    className: '高级前端开发班'
  }
}

// 格式化日期
const formatDate = (dateString) => {
  const date = new Date(dateString)
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  })
}

// 查看详情
const handleViewDetails = (point) => {
  // 实际项目中可能跳转到详情页
  ElMessage.info(`查看知识点"${point.title}"的详情`)
}


// 返回上一页
const goBack = () => {
  router.back()
}

// 页面加载时获取数据
onMounted(() => {
  getClassInfo()
})
</script>

<style scoped>
/* 可以添加一些组件特定的样式 */
</style>